<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>中国福利彩票</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">

<!--页面样式-->
<link rel="stylesheet" type="text/css" href="css/style.css" />

<style>
	body{ background:#f2f2f2 url(images/Dimg1.jpg) left top no-repeat; background-size:10rem;}
</style>

</head>
<body  style="width:10rem !important; margin:0 auto">
<script>
/*取设备宽度*/
	function rem(){
	var iWidth=document.documentElement.getBoundingClientRect().width;
	iWidth=iWidth>640?640:iWidth;
	document.getElementsByTagName("html")[0].style.fontSize=iWidth/10+"px";
	};
	rem();
	window.onorientationchange=window.onresize=rem    
</script>
<script src="js/jquery-1.7.2.min.js"></script>

	<div class="D_one"><img src="images/Dimg2.png"></div>
    
    <div class="D_cont">
    	
        <div class="D_two">
        	<dl>
            	<dt><img src="images/Dimg3.png"></dt>
                <dd><input type="text" placeholder="手机号/投注账号/身份证号码" class="DT_text font28 Weiruan c666666" id="nick" name="nick"></dd>
                <div class="clear"></div>
            </dl>
            <dl>
            	<dt><img src="images/Dimg4.png"></dt>
                <dd><input type="password" placeholder="请输入您的密码..." class="DT_text font28 Weiruan c666666" id="pwd" name="pwd"></dd>
                <div class="clear"></div>
            </dl>
        </div>
        
        <div class="D_three font24">
        	<div class="left DT_jp c666666"><input name="rememberPwd" type="checkbox" value="" checked id="rememberPwd">记住密码</div>
            <div class="right DT_jright c231815">
            	<a href="Rules.html">注册会员</a>
                <a href="Forgetpwd.html">忘记密码</a>
            </div>
            <div class="clear"></div>
        </div>
        
        <div class="D_four">
        	<input type="submit" value="登 陆"  onclick="login()"  class="font32 cfffff Weiruan" />
        </div>
    </div>
	
<!-- 弹出alert -->	
	<div class="falert" style="display: none;" id="warnInfoDiv">
		<div class="falert_t font30"><span style="margin-left:0.15rem">提示</span></div>
		<div class="falert_b"><span id="warnInfo"></span><img class="dianji_gb" style="position:absolute;right:0.1rem;top:0.15rem;cursor:pointer;" width="45rem" src="images/Fimg8.png" onclick="closeWarnInfoDiv('warnInfoDiv')"/></div>
	</div>
<!-- 弹出alert -->	
	
</body>
<script type="text/javascript">
	var channelId="";
   $(document).ready(function() {
	   setCookie('channelId',"1234567890",0);
	   channelId = getCookie("channelId");
	   if ($.cookie("rmbUser") == "true") { 
		   $("#rememberPwd").attr("checked", true); 
		   $("#nick").val($.cookie("userName")); 
		   $("#pwd").val($.cookie("passWord")); 
		} 
   });
 //注册成功调用login登录获得accountId和token
   function login(){
	 //验证用户名，密码
		if(!validateLogin('nick','pwd')){
			return;
		}
 	  var para = {
 			  	id:$('#nick').val(),
 				password:sha256_digest($('#pwd').val()),
 				channelId:channelId
 	        };
 		
 		$.ajax({
 			url : "../../api/accountSystem/login",
 			async:false,
 			type : "POST",
 			herder:{
 				'Accept':'application/json',
 				'Content-Type':'application/json'
 			},
 			dataType:"json",
 			contentType:"application/json",
 			data: JSON.stringify(para),
 			error:function(XMLHttpRequest, textStatus, errorThrown){
 				alert(errorThrown);
 			},
 			success: function(data, textStatus){
 				if(data.success == true){
 						setCookie('accountId',data.accountId,0);
 						setCookie('token',data.token,0);
 						setCookie('username',data.name,0);
 						saveUserInfo();
 						if(data.status==1000){
 							window.location.href='Register1.html?password='+sha256_digest($('#pwd').val())+'';
 						}else if(data.status==1002){
 							window.location.href='Register2.html?type=1';
 						}else if(data.status==2000){
 							window.location.href='MemberCenter.html';
 						}else{
 							window.location.assign(encodeURI('LoginDown.html'));
 							return;
 						}
 				}else{
 					window.location.assign(encodeURI('LoginDown.html?description='+data.description+''));
 					return;
 				}
 			}		
 		});
   }

 function saveUserInfo(){
	 if ($("#rememberPwd").attr("checked") == "checked") { 
		 var userName = $("#nick").val(); 
		 var passWord = $("#pwd").val(); 
		 $.cookie("rmbUser", "true", { expires: 7 }); // 存储一个带7天期限的 cookie 
		 $.cookie("userName", userName, { expires: 7 }); // 存储一个带7天期限的 cookie 
		 $.cookie("passWord", passWord, { expires: 7 }); // 存储一个带7天期限的 cookie 
	  }else{ 
		 $.cookie("rmbUser", "false", { expires: -1 }); 
		 $.cookie("userName", '', { expires: -1 }); 
		 $.cookie("passWord", '', { expires: -1 }); 
	  } 
 }
 
</script>
<script src="js/jsCallCookies.js"></script>
<script src="js/SHA256.js"></script>
<script src="js/validation.js"></script>
<script src="js/common.js"></script>
<script src="js/jquery.cookie.js"></script>
</html>
